Repository navigation
fix(theme)!: merge ThemeProvider's theme onto the parent and type it ThemeProp - #5239
Merged
Merged
Conversation
ThemeProvider put its theme into context as it was, and the prop was typed unknown, so a partial theme type-checked and then made Paper's components throw at render. It now merges its theme onto the theme above it with safeMerge, as a component's theme prop does, passes the theme above it on when theme is undefined, and is typed as a partial Theme. PaperProvider and Portal pass themes they have already merged to an internal provider, so nothing is merged twice. BREAKING CHANGE: ThemeProvider's theme prop is typed as a partial Theme instead of unknown, so TypeScript reports values that aren't a theme and keys the theme doesn't have.
The migration guide now says TypeScript checks ThemeProvider's theme, and has an entry on the merge. The theming guide shows ThemeProvider with a partial theme for one part of an app.
|
Found potential problems with the pull request:
|
Apex Sentinel · ✅ Approve · review of
|
| Command | What it does |
|---|---|
@apex-sentinel-staging note <context> |
Adds context; Sentinel re-checks the cited code |
@apex-sentinel-staging pivot <why> |
Says the finding is wrong; Sentinel re-checks the cited code |
@apex-sentinel-staging like |
Marks the finding as useful |
@apex-sentinel-staging dislike <why> |
Marks it as not useful, so it is not raised again |
On this conversation, comment @apex-sentinel-staging review to run a full review once again.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
ThemeProviderput itsthemeinto context unmerged, typedunknown. A partial theme such as{ colors: { primary: 'red' } }type-checked and then made Paper's components throw at render, andtheme={42}or a removedroundnesstype-checked too. It now mergesthemeonto the theme above it withsafeMerge, like a component'sthemeprop, and types it as a partialTheme, as onPaperProvider. A full theme gives the same result.Related issue
Fixes #5236
Screenshots / Videos
None: rendering doesn't change for a full theme.
Test plan
yarn typecheck,yarn lint,yarn test.src/theme/__tests__/ThemeProvider.test.tsx, "renders a partial theme and keeps the other keys of the theme above it"): it renders the button here.